﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;

namespace COFE.Core.Profile
{
    [Flags]
    public enum ParsableType : int
    {
        ParsePath = 0x1,
        ParsePathLookup = 0x2,
        HashCode = 0x3,
        Guid = 0x4
    }

    /// <summary>
    /// Reside in COFEShared, for parsing path.
    /// </summary>
    public interface IPathParser
    {
        ParsableType SupportedParseType { get; }
        IFileSystemInfo TryParsePath(IUserProfile profile, string path, ParsableType type, 
            EntryConstructionFlags flags = EntryConstructionFlags.Default);

        bool Exists(IUserProfile profile, string path, ParsableType type, out bool isFolder);
    }

    public static class IPathParserExtension
    {
       
        public static IFileSystemInfo TryParsePath(this IPathParser parser, IUserProfile userProfile,
            string path, ParsableType type, 
            EntryConstructionFlags flags = EntryConstructionFlags.Default)
        {
            return parser.TryParsePath(userProfile, path, type, flags);
        }

        /// <summary>
        /// Parse using COFEShared.CurrentUserProfile.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IFileSystemInfo TryParsePath(this IPathParser parser, string path, ParsableType type,
            EntryConstructionFlags flags = EntryConstructionFlags.Default)
        {
            return parser.TryParsePath(COFEShared.CurrentUserProfile, path, type, flags);
        }

    }
}
